home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 11
/
Amoszine 11 (Disk 2 of 2).adf
/
Ben_Wyatt_Source.lha
/
Shaded_3D_Stars.AMOS
/
Shaded_3D_Stars.amosSourceCode
Wrap
AMOS Source Code
|
2004-04-12
|
2KB
|
50 lines
' Shaded 3D Stars
' ~~~~~~~~~~~~~~~
' by Ben Wyatt, bwyatt@paston.co.uk
'
' Slow when uncompiled, but much better when compiled with the pro compiler
' when using F Plot or Turbo Plot
' Open a screen and do the boring old crap, that we all know how to do
Screen Open 0,320,256+(Ntsc*64),4,Lowres
Screen Display 0,128,37,320,256+(Ntsc*64)
Flash Off : Curs Off : Cls 0
Palette $0,$555,$888,$EEE
Double Buffer : Autoback 0
Hide On
' Guess what this does... it calls the 3D stars procedure (150 stars)
_3DSTARS[150]
Procedure _3DSTARS[STARS]
' Displays STARS amount of 3D stars
' Reserve some coords... (no Z coord for some reason ;-) )
Dim XSTAR(STARS),YSTAR(STARS)
SW=Screen Width*256 : SH=Screen Height*256
' Move these stars to random places to start with
For N=1 To STARS
XSTAR(N)=Rnd(SW)-SW/2 : YSTAR(N)=Rnd(SH)-SH/2
Next N
Repeat
For N=1 To STARS
X=Abs(XSTAR(N)) : Y=Abs(YSTAR(N))
If X>SW/2 or Y>SH/2
' Off the side of the screen
XSTAR(N)=Rnd(SW/2)-SW/4 : YSTAR(N)=Rnd(SH/2)-SH/4
Else
' Plot the star and add to it's x,y position
' Notice it uses powers of 2 (32, 256, 8192) to make it much
' faster with the pro compiler This bit calculates the colour
Plot(SW/2+XSTAR(N))/256,(SH/2+YSTAR(N))/256,Max(Min((X+Y)/8192,3),1)
Add XSTAR(N),XSTAR(N)/32 : Add YSTAR(N),YSTAR(N)/32
End If
Next N
' Swap screens, wait for a vbl and clear the screen :-)
Screen Swap : Wait Vbl : Cls 0
Until Key State(69) or Mouse Key>0
End Proc